<?php

namespace App\Console\Commands\Tools;

use App\Kuafu\Pay\BasePay;
use App\Kuafu\Pay\Channel\FuYou\FuYouBase;
use App\Kuafu\Pay\Service\PayService;
use App\Kuafu\Shop\Model\Shop;
use App\Kuafu\Shop\Service\ShopCameraSyncService;
use App\Kuafu\Shop\Service\ShopService;
use App\Kuafu\WaiMai\Enum\WaiMaiDBEnum;
use App\Kuafu\WaiMai\Model\WaiMaiShopMappingModel;
use App\Library\FeiShu\SendFs;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class DouyinBindCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'douyin:bind {shopCode} {poi}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '抖音门店绑定';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command
     *
     * @return int
     *
     */
    public function handle()
    {
        // 2023年12月31日 删除
        return ;

        $shopInfo = Shop::query()->where('shopCode', $this->argument('shopCode'))->first();
        $shopId   = $shopInfo->id;
        $poi      = $this->argument('poi');

        $orgDy = WaiMaiShopMappingModel::query()->where([
            'shopId'     => $shopId,
            'sourceType' => WaiMaiDBEnum::SOURCE_TYPE_DOUYIN
        ])->first();

        $douyin = WaiMaiShopMappingModel::query()->updateOrCreate(
            [
                'shopId'     => $shopId,
                'sourceType' => WaiMaiDBEnum::SOURCE_TYPE_DOUYIN
            ],
            [
                'thirdShopId'   => $poi,
                'thirdShopName' => $shopInfo->name
            ]
        );

        $this->info('门 店 ID : ' . $shopInfo->id);
        $this->info('门 店 名 称: ' . $shopInfo->name);
        $this->info('门 店 编 号: ' . $shopInfo->shopCode);
        $this->info('绑定 前 POI: ' . (empty($orgDy) ? ' ' : $orgDy->thirdShopId));
        $this->info('绑定 后 POI: ' . $douyin->thirdShopId);
        $this->info('绑定前门店名称: ' . (empty($orgDy) ? ' ' : $orgDy->thirdShopName));
        $this->info('绑定后门店名称: ' . $douyin->thirdShopName);
    }
}
